﻿using System;
using System.Collections.Generic;

// The image of the player is divided in two parts that are drawn seperately.
public class Player : GameObject
{
    public Coords2D CoordsOld { get; private set; }
    public Coords2D CoordsNew { get; private set; }

    private static readonly char[,] playerImage = new char[,]
    {
        { '╔', ' ', '╗' },
        { '╚', ' ', '╝' }
    };

    private const ConsoleColor playerColor = ConsoleColor.Yellow;

    public Player(Coords2D coords)
    {
        this.CoordsOld = new Coords2D();
        this.CoordsNew = coords;
        this.Color = playerColor;
        this.Image = playerImage;
    }

    public void MoveLeft()
    {
        MovePlayer(new Coords2D(this.CoordsNew.Row, this.CoordsNew.Col - 1));
    }

    public void MoveUp()
    {
        MovePlayer(new Coords2D(this.CoordsNew.Row - 1, this.CoordsNew.Col));
    }

    public void MoveRight()
    {
        MovePlayer(new Coords2D(this.CoordsNew.Row, this.CoordsNew.Col + 1));
    }

    public void MoveDown()
    {
        MovePlayer(new Coords2D(this.CoordsNew.Row + 1, this.CoordsNew.Col));
    }

    private void MovePlayer(Coords2D newCoords)
    {
        this.CoordsOld = this.CoordsNew;
        this.CoordsNew = newCoords;
    }
}
